package com.ll.bignumber;

import java.math.BigInteger;

/**
 * @author 刘龙
 * @version 1.0
 */
public class BigIntegerDemo {
    public static void main(String[] args) {
        // 需要处理很大的数,long不够用
        long l = 999999999999999999L;

        // 使用BigInteger
        BigInteger bigInteger = new BigInteger("999999999999999999999999999999999");
        BigInteger bigInteger1 = new BigInteger("1");

        // 999999999999999999999999999999999
        System.out.println(bigInteger);

        // 在对BigInteger进行算数运算时,需要使用对应的方法
        // 加 1000000000000000000000000000000000
        System.out.println(bigInteger.add(bigInteger1));
        // 减 999999999999999999999999999999998
        System.out.println(bigInteger.subtract(bigInteger1));
        // 乘 999999999999999999999999999999999
        System.out.println(bigInteger.multiply(bigInteger1));
        //除 999999999999999999999999999999999
        System.out.println(bigInteger.divide(bigInteger1));
    }
}
